package org.swim.core.entities;

import org.swim.remote.entities.IEntity;

public abstract class SwimEntity implements IEntity {

	private static final long serialVersionUID = 1L;

	public abstract Integer getId();

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;

		SwimEntity other = (SwimEntity) obj;
		if (getId() == null) {
			if (other.getId() != null)
				return false;
		} else if (!getId().equals(other.getId()))
			return false;
		return true;
	}

	@Override
	public int hashCode() {
		// final int hc;
		//
		// if (getId() == null) {
		// hc = super.hashCode();
		// } else {
		// hc = getId();
		// }
		//
		// return hc;

		final int prime = 31;
		int result = 1;
		result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
		return result;
	}
}
